/**
 * 
 */
package com.I9lou.se.lurker.remote;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 可索引的文档对象。
 * 由于Lucene3.0.3及之前的版本中的NumericField 不支持序列化，
 * 所以只能用自己的类来进行封装。
 * @author chenwei
 * @date 2011-03-29
 */
public class IndexableDocument implements java.io.Serializable {

	private static final long serialVersionUID = 1916853618154407911L;
	
	private boolean facetEnabled = false;

	private final List<IndexableField> fields = new ArrayList<IndexableField>();
	
	private final List<List<String>> facets = new ArrayList<List<String>>();
	
	private float boost;
	
	public void addFacet(List<String> facet) {
		facets.add(facet);
	}
	
	public Collection<List<String>> getFacets() {
		return facets;
	}
	
	public void addField(IndexableField field) {
		fields.add(field);
	}
	
	public void addFields(List<IndexableField> fields) {
		for(IndexableField field : fields) {
			addField(field);
		}
	}
	
	public Collection<IndexableField> getFields() {
		return fields;
	}

	public boolean isFacetEnabled() {
		return facetEnabled;
	}

	public void setFacetEnabled(boolean facetEnabled) {
		this.facetEnabled = facetEnabled;
	}
	
	public float getBoost() {
		return boost;
	}

	public void setBoost(float boost) {
		this.boost = boost;
	}

	@Override
	public String toString() {
		StringBuilder buffer = new StringBuilder("IndexableDocument@{");
		buffer.append("fields: \"").append( fields );
		buffer.append(" facets: \"").append( facets );
		return buffer.append("\"}").toString();
	}
	
}
